namespace SubhadraSolutions.Sharp.Logging.LogPublishers
{
    using SubhadraSolutions.Sharp.Logging.Contracts;
    using SubhadraSolutions.Sharp.Utils.Collections.Concurrent;
    using System;
    using System.Diagnostics;

    public abstract class AbstractLogPublisher : ILogPublisher
    {
        #region Events

        public event EventHandler<StoreFlushEventArgs<LogStoreItem>> OnFlush;

        #endregion Events

        #region Properties

        public string Name
        {
            get;
            set;
        }

        #endregion Properties

        #region Methods

        protected void raiseOnFlushEvent(StoreFlushEventArgs<LogStoreItem> e)
        {
            if (OnFlush != null)
            {
                try
                {
                    OnFlush(this, e);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }

        #endregion Methods
    }
}